\name{xcorr}
\alias{xcorr}
\title{ Cross-correlation }
\description{
Cross-correlation function using the Fast Fourier Transform.
}
\usage{
xcorr(x, y)
}
\arguments{
  \item{x,y}{ numeric sequences to be cross-correlated. }
}
\details{
  For vector valued inputs, \code{x} and \code{y} are post padded with
  zeros as follows:
  \code{ifft(fft(postpad(x, n) * Conj(fft(postpad(y, n)))))}
  where \code{n = length(x) + length(y) - 1}

  For matrices or a combination of vector and matrix inputs, the columns
  of \code{x} are correlated with the columns of \code{y}. Columns are
  recycled as necessary.
}
\value{
  For vector valued inputs, a vector of length equal to
  \code{length(x) + length(y) - 1}.

  For matrices or a combination of vector and matrix inputs, a matrix with
  \code{NROW(x) + NROW(y) - 1} rows and \code{max(NCOL(x), NCOL(y))} columns.
}
\references{
}
\author{ Based on the \code{conv} function ported from Octave to R by Tom Short.
  Christophe Tournery }
\seealso{ \code{\link{conv}}, \code{\link{convolve}}, \code{\link{fft}},
  \code{\link{ifft}}, \code{\link{fftfilt}}, \code{\link{poly}} }
\examples{
xcorr(c(1,2,3), c(1,2))
xcorr(c(1,2), c(1,2,3))
xcorr(matrix(1:6,ncol=2), c(1,2))
xcorr(c(1,2), matrix(1:6,ncol=2))
xcorr(matrix(1:6,ncol=2), matrix(1:4,ncol=2))
}
\keyword{ math }

